// example-appointment
var marry_columns=[
         {   // 最新约会时间
         	data:"update_time"  
         },
         {  //约会 类型
         	data : "appoint_status"
         },
         {   //发起人昵称
         	data :function(obj){
         		var span;
         		if(obj.appoint_status == "男邀约女" || obj.appoint_status == "男报名女约会"){
         			span = "<a href='Javascript:;' class='userData' data-toggle='modal' data-target='#myModal500'><span>"+obj.boy_nick+"</span><small style='display:none'>b" + obj.boy_id + "</small></a>";
         			return span
         		}
         		if (obj.appoint_status == "女报名男约会" || obj.appoint_status == "女邀约男") {
         			span = "<a href='Javascript:;' class='userData' data-toggle='modal' data-target='#myModal500'><span>"+obj.girl_nick+"</span><small style='display:none'>g" + obj.girl_id + "</small></a>";
         			return span
         		}
         		
         	}
         },
         {   //发起人电话
         	data : function(obj){
         		var span;
         		if(obj.appoint_status == "男邀约女" || obj.appoint_status == "男报名女约会"){
         			span = "<span>"+obj.boy_account+"</span>";
         			return span
         		}
         		if (obj.appoint_status == "女报名男约会" || obj.appoint_status == "女邀约男") {
         			span = "<span>"+obj.girl_account+"</span>";
         			return span
         		}
         	}
         },
         {   //发起人状态
         	data :function(obj){
         		var span;
         		if(obj.appoint_status == "男邀约女" || obj.appoint_status == "男报名女约会"){
         			span = "<span>"+obj.boy_state+"</span>";
         			return span
         		}
         		if (obj.appoint_status == "女报名男约会" || obj.appoint_status == "女邀约男") {
         			span = "<span>"+obj.girl_state+"</span>";
         			return span
         		}
         	}
         },
         {   //接收人昵称
         	data :  function(obj){
         		var span;
         		if(obj.appoint_status == "男邀约女" || obj.appoint_status == "男报名女约会"){
         			span = "<a href='Javascript:;' class='userData' data-toggle='modal' data-target='#myModal500'><span>"+obj.girl_nick+"</span><small style='display:none'>g" + obj.girl_id + "</small></a>";
         			return span
         		}
         		if (obj.appoint_status == "女报名男约会" || obj.appoint_status == "女邀约男") {
         			span = "<a href='Javascript:;' class='userData' data-toggle='modal' data-target='#myModal500'><span>"+obj.boy_nick+"</span><small style='display:none'>b" + obj.boy_id + "</small></a>";
         			return span
         		}
         	}
         },
         {  // 接收人电话
         	data : function(obj){
         		var span;
         		if(obj.appoint_status == "男邀约女" || obj.appoint_status == "男报名女约会"){
         			span = "<span>"+obj.girl_account+"</span>";
         			return span
         		}
         		if (obj.appoint_status == "女报名男约会" || obj.appoint_status == "女邀约男") {
         			span = "<span>"+obj.boy_account+"</span>";
         			return span
         		}
         	}
         },
         {
         	data : function(obj){  //接收人状态
         		var span;
         		if(obj.appoint_status == "男邀约女" || obj.appoint_status == "男报名女约会"){
         			span = "<span>"+obj.girl_state+"</span>";
         			return span
         		}
         		if (obj.appoint_status == "女报名男约会" || obj.appoint_status == "女邀约男") {
         			span = "<span>"+obj.boy_state+"</span>";
         			return span
         		}
         	}
         },
         {   // 约会交易状态 deal_state
         	data : function(obj){
         		var sapn;
         		if (obj.deal_state != "") { //交易中
         			
         			span = "<span class='suerSapan'>"+obj.deal_state+"</span>";
         			
         			return span
         		}else{
         			if (obj.girl_state == "取消" || obj.girl_state == "拒绝" ||obj.boy_state == "取消" || obj.boy_state == "拒绝") {// 拒绝
         				if (obj.girl_state == "取消" || obj.girl_state == "拒绝") {
         					if (obj.girl_change_cause == "") {   // 无理由
         						span = "<span class='userReason'>约会取消</span>";
         						return span
         					}else{  //有理由
         						span = "<span class='userReason1'>" + obj.girl_change_cause + "</span>";
         						return span
         					}	
         				}
         				if(obj.boy_state == "取消" || obj.boy_state == "拒绝") {
         				    if (obj.boy_change_cause == "") {   // 无理由
         				    	span = "<span class='userReason'>约会取消</span>";
         						return span
         				    } else{   //有理由
         				    	span = "<span class='userReason1'>"+obj.boy_change_cause+"</span>";
         				    	return span
         				    }
         				} else {
         				
         				}
         				
         			}else{
         				span = "<span class='userReject'>待确认</span>";
         				 return span
         			}
         		}
         	}
         }



];
//要在 表格加载完成之后再添加样式 否则 只有第一页有效果 
$("#example-appointment").ajaxComplete(function(){
	$(".suerSapan").parent().css({"background":"rgba(44,193,210,.5)","color":"white"}); //交易中
    $(".userReject").parent().css({"background":"rgba(126, 144, 239, 0.5)","color":"white"}); //待确认
    $(".userReason").parent().css({"background":"rgb(185, 180, 180)","color":"white"}); // 无理由
    $(".userReason1").parent().css({"background":"rgb(185, 180, 180)","color":"red"}); //有理由
});
$("#recordDate").click(function(){
	Data_table("#example-appointment", address1 + "/admin/appoint/index", marry_columns, false);
	
})


	//女生 时间范围选择
	var timestamp = new Date().getTime();
	var torday7 = timestamp - 604800000; //  当前时间的7天前
	var startDate = "";
	var endDate = "";
	var sendMardata={};

	function fmtDate(obj) {
		var date = new Date(obj);
		var y = 1900 + date.getYear();
		var m = "0" + (date.getMonth() + 1);
		var d = "0" + date.getDate();
		return y + "-" + m.substring(m.length - 2, m.length) + "-" + d.substring(d.length - 2, d.length);
	}
	var dateRange1 = new pickerDateRange('date3', {
		isTodayValid: true,
		startDate: fmtDate(torday7),
		endDate: fmtDate(timestamp),
		startToday: false,
		stopToday: true,
		needCompare: false,
		defaultText: ' 至 ',
		autoSubmit: true,
		inputTrigger: 'input_trigger3',
		theme: 'ta',
		success: function(obj) {

			$("#dCon3").html('开始时间 : ' + obj.startDate + '<br/>结束时间 : ' + obj.endDate);
		}

	});
	$("#date3").bind("DOMNodeInserted", function(e) {
		var s = $(e.target).text();
		sendMardata.appointMinTime = s.substr(0, 10);
		sendMardata.appointMaxTime = s.substr(13, 22);
		Data_table("#example-appointment", address1 + "/admin/appoint/index", marry_columns, false,sendMardata);
		
	})
